home *** CD-ROM | disk | FTP | other *** search
/ Magnum One / Magnum One (Mid-American Digital) (Disc Manufacturing).iso / d21 / concure.arc / MEMORY.TXT < prev   
Text File  |  1989-09-20  |  26KB  |  533 lines

  1. Memory usage by DOS multitasking software
  2.  
  3. An OMNIVIEW Application Note
  4. Copyright (c) 1989 Sunny Hill Software
  5.  
  6. Rev. 1: 09/05/89
  7.  
  8.  
  9.         When evaluating memory usage from the standpoint of
  10.         multitasking software two general rules apply:
  11.  
  12.             1) An 80386 system is the best to have.
  13.             2) Except on a 80386, any hardware EMS is better
  14.                than an emulator and the later the EMS
  15.                software AND HARDWARE the better.
  16.  
  17.         In order to appreciate the validity of these rules, one
  18.         must understand the limits of the PC hardware and their
  19.         historical basis.
  20.  
  21.     Address lines, A Primer on Electric Rocks:
  22.  
  23.         If you look at a microprocessor chip you will see that it
  24.         is a flat rock with a lot of flat wires stuck on the
  25.         sides: it's an electric rock. Some of the electricity is
  26.         used to power the chip and some is used for getting data
  27.         in and out of the rock and some is used for controlling
  28.         other rocks.  Regardless of the "kind" of wire, each is
  29.         (for the purposes of our discussion), always either on or
  30.         off. Since each of the lines have only two "states" the
  31.         microprocessor forms the basis of a "binary" computer:
  32.         Meaning based on two values.
  33.  
  34.         Memory chips are another special kind of binary
  35.         electrical rock.  Some of the wires on microprocessors
  36.         are dedicated to controlling memory rocks. These wires
  37.         are called "address lines".  In order to form an address,
  38.         each of the address lines is first given a value which
  39.         represents whether it is "on" or "off".  When a wire is
  40.         "turned on" it is said to have a value of one, and when
  41.         "turned off" a value of zero.
  42.  
  43.         If you take all the values of the address lines together
  44.         and add them up using base 2 arithmetic you come up with
  45.         a numerical value that represents the address (or
  46.         location) of some kind of data.  Each memory rock is like
  47.         a street, it has lots of places where data live. Which
  48.         memory rock is assigned a given range of addresses
  49.         depends on where it is physically located in a given
  50.         computer. The number of memory rocks that a computer can
  51.         use at one time is determined by the number of address
  52.         lines stuck on the side of the microprocessor.
  53.  
  54.         When IBM first introduced the PC in 1980, it was based on
  55.         the 8088 microprocessor from Intel.  This chip evoluved
  56.     from the 8080 chip that ran the popular CP/M operating
  57.     system. One of the Big Advantages of the 8088 over the
  58.     8080 was the one mega-byte address space of the new chip:
  59.     It had 20 different address lines instead of just 16. It
  60.     had more reach.
  61.  
  62.         When the folks at IBM were designing the PC, they decided
  63.         to include an expansion bus on the PC mother board.
  64.         Since a lot of cards that IBM could foresee being plugged
  65.         into this bus would need to have memory rocks that the
  66.         8088 could address, these cards would have to take up
  67.         some of the PC's address locations. IBM decided that
  68.         address locations above the 640K boundary would be
  69.         reserved for these plug in cards.
  70.  
  71.         Since the PC's RAM limit was still ten times what the
  72.         8080 had to offer, many at the time considered it an
  73.         absurdly large amount of space to run programs in; but,
  74.         to paraphrase Murphy, applications grow to consume all
  75.         available resources. Memory soon became tight and those
  76.         who decried the abundance of the 640K limit soon made
  77.         those back issues unavailable.
  78.  
  79.         The 8080 and the 8088 each have a seperate set of address
  80.         lines that they can use. One is for Input and Output
  81.         (I/O) and the other is for memory. The things that you
  82.         will find living at I/O addresses are generally known as
  83.         "peripheral devices": Things like printers, disk drives,
  84.         displays and keyboards. I/O lines are for controlling
  85.         hardware.
  86.  
  87.         When memory became tight on CP/M machines, some
  88.         manufacturers implemented a scheme known as "memory
  89.         paging". When you build a machine that uses memory paging
  90.         you take some of the I/O lines and connect them to yet
  91.         another kind of special electric rock: These rocks switch
  92.         the memory address lines from one set of memory rocks to
  93.         another based on the numbers that appear on the I/O
  94.         lines.  If the right set of numbers are set for a given
  95.     memory rock, the electrical signals from the CPU's memory
  96.     address lines are sent there and it becomes "addressable"
  97.     by the CPU.
  98.  
  99.         In a paged memory system, when you fill up one set of
  100.         memory rocks you can send some numbers down the I/O lines
  101.         and magically have a brand new bunch of memory to use.
  102.         It's like turning a page in a spiral notebook: If you
  103.         want to see what you wrote down before, just turn back
  104.         the page.
  105.  
  106.         When memory became tight on 8088 machines, manufactures
  107.         again relied on memory paging to make room for more
  108.     memory rocks.  Being manufacturers of snazzy modern
  109.     devices they didn't want to make references to spiral
  110.     notebooks so they renamed the trick. They called it using
  111.     Expanded Memory.
  112.  
  113.  
  114.     Types of Expanded Memory:
  115.  
  116.         "LIM" refers to a specification for constructing paged
  117.         memory cards (and drivers for them) that was established
  118.         by a committee representing Lotus, Intel and Microsoft;
  119.         the numbers you often see associated with this acronymn
  120.         describe the version number of the specification. "EEMS"
  121.         refers to another specification for the same stuff called
  122.         the Enhanced Expanded Memory Specification which was
  123.         developed by a committee representing AST, Quadram and
  124.         Ashton-Tate. EEMS improved on LIM 3.2; LIM 4.0 includes
  125.         the improvements from EEMS plus some new things of its
  126.         own and has been accepted by AST, Quadram and
  127.         Ashton-Tate. Regardless of the name, these specifications
  128.         all describe some way of paging through memory.
  129.  
  130.     Another memory specification you have probably heard
  131.     about is called the eXtended Mememy Specification (XMS).
  132.     This was developed by AST as well the the people who
  133.     wrote the LIM specification. XMS does not deal with
  134.     paged memory hardware but with extended memory which is,
  135.     by definition, the memory starting at the one megabyte
  136.     boundary. While this type of memory has its uses (loading
  137.     TSRs, etc.), it is has no direct use in multitasking.
  138.  
  139.         LIM 3.2 is the least common denominator of the three EMS
  140.     standards. With this kind of memory HARDWARE all EMS
  141.     pages have an address in a suburb of the mother board
  142.     memory called the Page Frame. Here is some census data on
  143.     the Page Frame:
  144.  
  145.             1) Each EMS page of memory is 16K bytes long.
  146.             2) The page frame holds four of these 16K pages (a
  147.                total of 64K bytes).
  148.             3) The page frame is located above 640K and its
  149.                lowest address is evenly divisible by 16K (it
  150.                starts and ends on a page boundary).
  151.             4) The lowest allowable address is at segment 0C000h
  152.                (768K) and its highest starting address is at
  153.                segment 0E000h (896K).
  154.  
  155.         It is important to remember that real EMS works by
  156.         sending electrons down the I/O wires and causing a
  157.         hardware switch to change which page of memory the
  158.         microprocessor can use. The switches that control the
  159.         accessibility of the pages of memory are called "page
  160.         registers".  A LIM 3.2 card has four page registers and
  161.     thus four "physical memory pages".  LIM 3.2 hardware
  162.     provides 64K of additional, simultaneously addressable
  163.     memory above 640K.
  164.  
  165.         It is possible to run a program in the page frame
  166.         (OVSHELL runs there when you use XSHELL to load it there)
  167.         but the program must be small and, in doing so, it
  168.         violates some rules for "well behaved" programs.  Because
  169.         of the limited size and the nature of the page frame,
  170.         multitaskers use LIM 3.2 for swapping programs but not
  171.         for running applications.
  172.  
  173.         Capitalizing on the limitations of LIM 3.2, the committee
  174.         behind the EEM standard decided to produce hardware with
  175.         64 page registers. This made available 1M bytes of memory
  176.         (1024K) that the EMS hardware could simultaneously keep
  177.         track of. EEMS also did away with the limitation that EMS
  178.         memory could only be "mapped" into the page frame: This
  179.         meant that EMS would no longer be limited to the suburbs
  180.         but could move uptown to the mother board.
  181.  
  182.         The LIM 4.0 standard provided for a maximum of 255 page
  183.         registers. It also provides for the naming of allocated
  184.     memory pages (those that are in use) and for a hardware
  185.     mechanism for keeping track of the EMS context known as
  186.     Alternate Mapping Register Sets (AMRS). The EMS context
  187.     is the combined state of the page registers (that is, the
  188.     record of which memory rocks are in use at a given time).
  189.     Copies of the LIM 4.0 standard are available from the
  190.     sponsors.
  191.  
  192.  
  193.     Swapping:
  194.  
  195.         OMNIVIEW treats LIM 3.2 memory in pretty much the same
  196.         way as a RAM disk with the following exceptions:
  197.  
  198.             1) When LIM 3.2 memory fills up, OMNIVIEW will begin
  199.                swapping programs to the drive that was current
  200.                when OMNIVIEW was started.  You can over-ride this
  201.            drive selection with the SWAP environment variable
  202.            but you can not chain drives together to create a
  203.                larger swapping space.
  204.             2) You can limit the amount of EMS that a process can
  205.                access.
  206.  
  207.         Whether using EMS or disk, when loading a swappable
  208.         program, there are three memory requirements that must be
  209.         fulfilled:
  210.  
  211.             1) There must be at least as much free memory
  212.                available as is "required" by the partition.
  213.             2) The partition must be large enough to house the
  214.                programs that are run inside it.
  215.             3) There must be enough swapping space to hold all
  216.                the currently active partitions as well as the
  217.                partition being loaded.
  218.  
  219.         The first two requirements also apply to non-swappable
  220.         processes. If the the first or third requirements are not
  221.         met, OMNIVIEW will display a "Not enough memory" message.
  222.         DOS will state that there is "Not enough memory to load
  223.         program" if the second requirement is not met.
  224.  
  225.  
  226.     Backfilling and concurrent processes:
  227.  
  228.         Theoretically, with EEMS or LIM 4.0 you can map memory
  229.     into the lower 640K and you can have it start anywhere
  230.     and be as big as you'ld like (within the limit of the
  231.     8088's address space). In reality this is not so.
  232.  
  233.         The problem with using EMS on the motherboard is one of
  234.         the nature of the hardware and of the assumptions made
  235.         about it. Remember that the page registers determine
  236.     which address lines are connected to which memory rocks
  237.     on an EMS board. Also remember that there are only a certain
  238.     number of address lines on the CPU. It is also helpful to
  239.     realize that electrons are indecisive, easily confused
  240.     and dangerous when dazed.
  241.  
  242.         If you tell an EMS board to map some memory rocks into
  243.         the lower 640K on a 640K motherboard then some
  244.         combination of turned on address lines will point the way
  245.         to two different memory rocks.  Electrons traveling down
  246.         the address lines in such a situation will not know which
  247.         way to go.  A struggle will ensue between the memory
  248.         rocks over the favor of the electrons and the stability
  249.         of your system will be laid to waste in the froe.
  250.  
  251.         To make full use of the expanded memory hardware on an
  252.         EEMS board you must first REMOVE MEMORY from the
  253.         motherboard. Once this is done the addresses on the
  254.         motherboard will be vacant and you can safely occupy them
  255.         with the rocks from EMS. This process of vacating and
  256.         rehabitating the mother board real estate is known as
  257.         "back filling".
  258.  
  259.         What you do with the chips that you had to remove from
  260.         the mother board depends on whether or not they will fit
  261.         on your particular EMS board and the current market price
  262.         of used DRAMS. On some machines, it also depends on your
  263.         BIOS.
  264.  
  265.         When a machine is first turned on, it starts executing a
  266.         program that is kept in a Read Only Memory (ROM) rock.
  267.         This program is called the Pre-Operational Startup Test
  268.         (POST). Some BIOSs are written by people who didn't
  269.         think about using EMS memory and expected the motherboard
  270.     to contain some minimum amount of RAM. Part of the job
  271.     of the POST is to verify that this memory is operational
  272.     by writing and reading back some value for each memory
  273.     address in the presupposed range. If the POST writes to a
  274.     memory address where no memory rock is installed, it will
  275.     read back garbage; the memory test will fail, and the
  276.     machine will never start up.
  277.  
  278.         Your hardware manuals should state the minimum amount of
  279.         RAM you can have on the motherboard and still start it
  280.         up.  If you can't discern this from reading the manual
  281.         you will have to get that information from the people who
  282.         sold you the machine.  If all else fails you can always
  283.         experiment on your own, removing one (or possibly two)
  284.     bank(s) of chips at a time until it fails to start up.
  285.     On some machines the memory test works on banks of memory
  286.     and you may be able to substitute smaller memory chips in
  287.     the required banks to reduce the conventional memory.
  288.  
  289.         Once you have removed all but the minimum amount of RAM
  290.         from the mother board, you should tell your Expand Memory
  291.     Manager (EMM) software about it so that it can move its
  292.     memory into the vacant addresses. The documentation
  293.     for your EMS card should tell you how to do this. When
  294.     this is done, your machine should be backfilled the next
  295.     time you start it up. You can verify that all went well
  296.     by running CHKDSK, MAPMEM or other RAM measuring program
  297.     and insuring that the amount of system RAM exceeds the
  298.     conventional memory on the motherboard.
  299.  
  300.         Once backfilling is completed then chunks of memory,
  301.         equivalent in size to the amount of memory that was
  302.         backfilled, can be paged in and out of the 8088 address
  303.     space with the flick of an I/O line.  Since hardware
  304.     memory paging is quite fast the programs which live in
  305.     the backfilled EMS can be run in the background - as long
  306.     as they can be switched in.
  307.  
  308.         To illustrate the implications of this last point, let's
  309.         assume that a you had an AT motherboard requiring at
  310.         least 512K to start up. Let's further assume that the
  311.         board was backfilled from a 1M EMS board to the 640K
  312.         boundary with EEMS memory and that you had 512K free
  313.         after loading OMNIVIEW. In this case you would have 384K
  314.         of free conventional memory and 128K of free EMS memory
  315.     addressable in the lower 640K.
  316.  
  317.         The term Transient Program Area (TPA) describes the area
  318.     of memory available after the operating system and all
  319.     its extensions are loaded: It is the amount of RAM you
  320.     have to run normal (transient vs. resident) programs. In
  321.     the example above the size of the TPA is 512K.
  322.  
  323.         A partition must completely fit into the backfilled block
  324.         of EMS in order for it to be moved around using hardware
  325.         paging. The alternative to hardware paging is to
  326.         physically copy every byte of the existing partition from
  327.         the TPA into EMS and then to copy every byte of the next
  328.         partition from EMS into the TPA.
  329.  
  330.         Physical copying would have to happen each time a new
  331.         program is scheduled to run and, since it takes a
  332.         relatively long time to copy partitions compared to the
  333.         time the partitions get to run, the only thing that would
  334.         be happening in the system is the copying of process
  335.         data.  Obviously, it is undesirable to have the
  336.         multitasker be the only program running in the computer.
  337.         Only those processes that can be fit in the TPA without
  338.         having to physically copy them there will run
  339.     concurrently.
  340.  
  341.         In our hypothetical machine, five 128K swappable programs
  342.         could be loaded as well as one 384K non-swappable
  343.         process. Since each of the above processes could run
  344.         concurrently they would all be described as "waiting" by
  345.         the OMNIVIEW status program (OVSTAT.EXE).  Note that the
  346.         total size of all partitions is well over 640K.
  347.  
  348.         If the larger partition had been set up as swappable it
  349.         would have used up EMS swapping space, leaving room for
  350.         only three other small partitions; since it would have to
  351.         be copied in and out of the TPA it would be shown as
  352.         "swapped" by OVSTAT if was not already in the TPA.
  353.  
  354.         If the big partition above had been made greater than
  355.         384K and swappable then, whenever it was in the TPA, it
  356.         would be the only process running.  The reason for this
  357.         is that it would be taking up part of the backfilled
  358.         memory needed by the other processes, blocking them from
  359.         being paged in.  If the big partition above had been made
  360.         greater than 384K and nonswappable then it could never be
  361.         moved out of the way of the other processes and it would
  362.         be the the only thing running as long as it was active.
  363.  
  364.         For a variety of reasons, even with hardware page
  365.         mapping, the time required to switch between processes on
  366.         anything less than a 80386 based system precludes
  367.         reliable process switches at a rate neccesary for
  368.         handling hardware interrupts in real time. Consequently,
  369.         with 80286 and earlier processors, communications
  370.         programs must be non-swappable.
  371.  
  372.  
  373.     Video filling and expanding the TPA:
  374.  
  375.         Remember that the TPA is the amount of free RAM after all
  376.         the resident programs are loaded. Also remember that the
  377.     640K barrier was established to allow peripheral cards
  378.     room to fit into the 8088's address space. The standard
  379.     adapter cards with the lowest addresses are used for
  380.     video output; we can map EMS memory between the bottom
  381.     address of these cards and the 640K boundary since there
  382.     is no installed memory to cause a conflict. The practice
  383.     of mapping EMS between the 640K boundary and the bottom
  384.     of the installed video adapter memory is known as "video
  385.     filling" and OMNIVIEW does this automatically when
  386.     possible.
  387.  
  388.         The amount of memory to be gained by the video fill
  389.     depends on the video adapter installed in the system.
  390.     The size of the TPA after topfilling depends on the size
  391.     of the topfilled region and the amount of memory that was
  392.     free before OMNIVIEW was loaded.  The table below shows
  393.     the possibilites for each standard adapter type.
  394.  
  395.             Video        Memory          Effective
  396.             Adapter      Gained          System Memory
  397.       ----------------------------------------------
  398.             EGA/VGA      0               640K
  399.             MDA/Herc     68K             704K
  400.             CGA          90K             736K
  401.  
  402.  
  403.     Allocating upper memory blocks using OMNIHIGH:
  404.  
  405.         Included on the distribution disk is a program called
  406.         OMNIHIGH.COM. This program will allocate 48K of EMS
  407.         memory in the region between the top of the system video
  408.         adapter and the bottom of the page frame. This memory
  409.         will then be used to load the OMNIVIEW.EXE file into this
  410.         memory region, significantly reducing OMNIVIEW's use of
  411.         the TPA.
  412.  
  413.         If OMNIHIGH issues an error message saying "Cannot
  414.         allocate upper memory blocks" then the program could not
  415.     gain access to the required 48K EMS memory block. This
  416.     could be because that that region of memory is already
  417.     being used. On a 80286 or earlier system it could also be
  418.     because your EMS software does not support the neccesary
  419.     functions or because there are not enough physical EMS
  420.     pages to establish the memory region. On an 80386 system
  421.     it could be that you did not tell the memory manager to
  422.     "include" the necessary EMS region or that the region you
  423.     stated confilcted something else in the system.
  424.  
  425.  
  426.     Extended Memory, RAM disks and EMS Emulators:
  427.  
  428.         The 80286 processor has 24 address lines providing a 16M
  429.         byte address space. As we mentioned earlier, the upper
  430.     15M bytes of the '286 address space are known as
  431.     "extended memory". In order to access extended memory the
  432.     machine must be in the "protected mode" of operation. DOS
  433.     programs however operate in what is known as the "real
  434.     mode" and are incompatible with the protected mode
  435.     operation of the '286. Consequently, extended memory is
  436.     inaccessible by DOS programs without first switching the
  437.     microprocessor into protected mode, reading the data
  438.     into some place in the lower 1M byte address space and
  439.     then switching back into "real" mode.
  440.  
  441.         In order to switch between protected and real mode the
  442.         machine must be reset, this has been likened to "turning
  443.         off the car to shift gears". Additionaly, during the
  444.         switch to real mode, interrupts can be lost resulting in
  445.         communications or other interrupt related errors.
  446.         Regardless of the effectiveness of this approach it is
  447.         what is required by a DOS program to be able to access
  448.         extended memory and is used by VDISK and other programs.
  449.         OMNIVIEW does not utilize extended memory directly.
  450.  
  451.         EMS emulators work in essentially the same way as VDISK
  452.         or other extended memory RAM disk programs. The only
  453.         difference is that VDISK wants you to think it's
  454.         controlling a fast disk drive while the EMS emulators
  455.         want you to think they're controlling EMS hardware. The
  456.         process of switching to and from protected mode involves
  457.         a fair amount of overhead by itself. Additionally, all
  458.     the data from the partition in the TPA must be physically
  459.     copied into the page and from there into extended memory
  460.     then the data for the partition in EMS must be physically
  461.     copied from extended memory into the page frame and from
  462.     there into the TPA.  Another complication with an EMS
  463.     emulator is that to provide a full page frame it must
  464.     take at least 64K away from the memory that would
  465.     otherwise be in the TPA.  Setting up an extended memory
  466.     RAM disk may be a better solution.
  467.  
  468.  
  469.     80386 based system operations:
  470.  
  471.         On an 80386 system EMS hardware capabilities can be
  472.         provided using the virtual machine capabilites introduced
  473.         with that chip.
  474.  
  475.         In order to utilize these features of the 80386 a Virtual
  476.         Control Program (VCP) such as Qualitas' 386^MAX is
  477.         required. These programs are loaded from your CONFIG.SYS
  478.         file and eliminate the need for physically backfilling
  479.     the motherboard. These programs also automatically
  480.     perform video filling and provide the capability to
  481.     allocate upper EMS blocks. In addition to all this,
  482.     386^MAX can also load other device drivers and TSR's into
  483.     the 640K to 1M byte addres range and provides XMS
  484.     support.
  485.  
  486.         Using 386^MAX on a 20MHz '386, OMNIVIEW can run up to ten
  487.         programs concurrently - answering 100,000 interrupts per
  488.     second. Total impact on the TPA will be 10-30K depending
  489.     on your system.
  490.  
  491.         Because 386^MAX is a software product there are some
  492.         things things that you must do which would not be
  493.     required by a hardware EMS product. You must specify the
  494.     range of addresses to use for any upper EMS blocks and
  495.     also specify the number of AMRSs that you wish it to use.
  496.     Also, if you wish to exclude any of the '386 memory from
  497.     conversion to EMS, you must tell it this as well.
  498.  
  499.         The following entry in the CONFIG.SYS file is recommended
  500.         for 386^MAX:
  501.  
  502.         DEVICE=386MAX INCLUDE=D400-E000 AMRS=11 [others] SCREEN
  503.  
  504.     "INCLUDE" sets up the 48K EMS block at the address
  505.     specified. This address is satisfactory for most systems.
  506.     If you have OMNIHIGH complains about not being able to
  507.     "allocate upper memory" then run 386MAX.COM with the '/E'
  508.     option and verify the that this block was "included": If
  509.     it was then the block has been used by another program.
  510.     If the block is included then either you made a mistake
  511.     typing in the command or else the specified region
  512.     conflicts with something else in the system, probably
  513.     with a ROM on disk controller, network or terminal
  514.     emulator card. You can find the location of these ROMs by
  515.     running 386MAX.COM  with the '/R' option and then change
  516.     the include address to avoid the ROMs.  If there is no
  517.     way to fit a 48K block into 'high DOS' then you will have
  518.     to load OMNIVIEW into low memory.
  519.  
  520.     "AMRS" statement allocates Alternate Mapping Register
  521.     Sets. You should establish the number of AMRSs to be one
  522.     more than the number of processes that you will want to
  523.     run simultaneously.
  524.  
  525.     SCREEN tells 386^MAX to virtualise the video hardware
  526.     used by most programs. This allows programs that write
  527.     directly to the screen in text and CGA graphics modes to
  528.     operate in the background without interfering with the
  529.     foreground program's display.
  530.  
  531.     "[others]" refers to any other arguments you
  532.     have to supply for your system.  Consult the 386^MAX
  533.     manual and README file for details.